package tr.edu.metu.is.mega.server.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

/**
 * The persistent class for the submission database table.
 * 
 */
@Entity
@NamedQuery(name="querySubmissionsToReview", query ="select s from Reviewer r, Submission s where r.reviewerTeam.pkid=:reviewerTeam and r.team=s.team and s.activity=r.activity")
public class Submission implements Serializable, tr.edu.metu.is.mega.server.core.BaseEntity {

    private static final long serialVersionUID = -8434801953100372860L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer pkid;

    private String filepath;

    @Column(name = "fk_relatedsubmission")
    private Integer fkRelatedsubmission;

    private Timestamp submissiondate;

    // bi-directional many-to-one association to Activity
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fk_activity")
    private Activity activity;

    // bi-directional many-to-one association to Systemuser
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fk_submittedby")
    private Systemuser systemuser;

    // bi-directional many-to-one association to Team
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fk_submitterteam")
    private Team team;

    // bi-directional many-to-one association to Submissionrevision
    @OneToMany(mappedBy = "submission")
    private List<Submissionrevision> submissionrevisions;

    /**
     * Default constructor.
     */
    public Submission() {
    }

    /**
     * Returns pkid.
     * 
     * @return the pkid
     */
    @Override
    public Integer getPkid() {
        return pkid;
    }

    /**
     * Sets pkid value.
     * 
     * @param pkid the pkid to set
     */
    @Override
    public void setPkid(Integer pkid) {
        this.pkid = pkid;
    }

    /**
     * Returns filepath.
     * 
     * @return the filepath
     */
    public String getFilepath() {
        return filepath;
    }

    /**
     * Sets filepath value.
     * 
     * @param filepath the filepath to set
     */
    public void setFilepath(String filepath) {
        this.filepath = filepath;
    }

    /**
     * Returns fkRelatedsubmission.
     * 
     * @return the fkRelatedsubmission
     */
    public Integer getFkRelatedsubmission() {
        return fkRelatedsubmission;
    }

    /**
     * Sets fkRelatedsubmission value.
     * 
     * @param fkRelatedsubmission the fkRelatedsubmission to set
     */
    public void setFkRelatedsubmission(Integer fkRelatedsubmission) {
        this.fkRelatedsubmission = fkRelatedsubmission;
    }

    /**
     * Returns submissiondate.
     * 
     * @return the submissiondate
     */
    public Timestamp getSubmissiondate() {
        return submissiondate;
    }

    /**
     * Sets submissiondate value.
     * 
     * @param submissiondate the submissiondate to set
     */
    public void setSubmissiondate(Timestamp submissiondate) {
        this.submissiondate = submissiondate;
    }

    /**
     * Returns activity.
     * 
     * @return the activity
     */
    public Activity getActivity() {
        return activity;
    }

    /**
     * Sets activity value.
     * 
     * @param activity the activity to set
     */
    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    /**
     * Returns systemuser.
     * 
     * @return the systemuser
     */
    public Systemuser getSystemuser() {
        return systemuser;
    }

    /**
     * Sets systemuser value.
     * 
     * @param systemuser the systemuser to set
     */
    public void setSystemuser(Systemuser systemuser) {
        this.systemuser = systemuser;
    }

    /**
     * Returns team.
     * 
     * @return the team
     */
    public Team getTeam() {
        return team;
    }

    /**
     * Sets team value.
     * 
     * @param team the team to set
     */
    public void setTeam(Team team) {
        this.team = team;
    }

    /**
     * Returns submissionrevisions.
     * 
     * @return the submissionrevisions
     */
    public List<Submissionrevision> getSubmissionrevisions() {
        return submissionrevisions;
    }

    /**
     * Sets submissionrevisions value.
     * 
     * @param submissionrevisions the submissionrevisions to set
     */
    public void setSubmissionrevisions(List<Submissionrevision> submissionrevisions) {
        this.submissionrevisions = submissionrevisions;
    }

}
